package com.bit.demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2022-11-13
 * Time: 20:13
 */

class Animal {
    public String name;
    public int age;
    protected int count;

    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println("eat()");
        System.out.println(count);
    }
}

class Dog extends Animal{
    public Dog(String name,int age) {
        super(name,age);
    }
}
class Bird extends Animal{
    public String wing;
    public Bird(String name,int age,String wing) {
        super(name,age);
        this.wing = wing;
    }
    public  void fly() {
        System.out.println(name + "fly()" + age);
    }
}
public class TestDemo {


    public static void main(String[] args) {
/*        Dog dog = new Dog("haha",19);
        Animal animal = dog;*/
        Animal animal = new Dog("haha",19);//父类引用  引用  子类对象
    }
    public int val = 10;
    public int val2 = 99;
    public static void main1(String[] args) {

        Dog dog1 = new Dog("nengneng",18);
        System.out.println(dog1.name);
        dog1.eat();
        Bird bird = new Bird("heihei",19,"我要的飞翔");
        System.out.println(bird.name);
        bird.eat();
        bird.fly();
    }
}
